﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Runda.EShop.Bll;
using Runda.EShop.Common.Entity;
using System.Web.Script.Serialization;

namespace Runda.EShop.Web.Service
{
    public partial class OrderService : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/plain"; 
            JavaScriptSerializer jss = new JavaScriptSerializer();
            AjaxOperateResult result = new AjaxOperateResult();
            if (Request["ProductID"] != null && Request["Count"] != null)
            {
                BizShopCartEntity entity = new BizShopCartEntity();
                entity.ProductID = new Guid(Request["ProductID"]);
                entity.CustomerID = base.User.Identity.LoginUser.UserID;
                entity.Quantity = Convert.ToInt32(Request["Count"]);
                entity.CreatedAt = DateTime.Now;
                entity.Deleted = false;
                BizShopCartBll bll = new BizShopCartBll();
                bll.AddProductToShopcart(entity);

             
                result.IsSuccess = true;
                result.Result = string.Empty;
                result.Result2 = string.Empty;

                Response.Write(jss.Serialize(result));
            }
            else
            {
                result.IsSuccess = false;
                result.Result = string.Empty;
                result.Result2 = string.Empty;

                Response.Write(jss.Serialize(result));
            }
            Response.End();
        }
    }
}